package com.vogue.supplymall.shop.domain.dao.impl;

import com.vogue.supplymall.shop.domain.dao.ProductAttrvalueDao;
import com.vogue.supplymall.shop.domain.mapper.ProductAttrvalueMapper;
import com.vogue.supplymall.shop.domain.model.ProductAttrvalue;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Repository;

/**
 * @Aouthor: zhangliang
 * @Date: Create in 2017-12-14
 */
@Repository("productAttrvalueDao")
public class ProductAttrvalueDaoImpl extends BaseDaoImpl<ProductAttrvalue, Long> implements ProductAttrvalueDao {
	@Resource
	private ProductAttrvalueMapper productAttrvalueMapper;
	
	@Override
	public List<ProductAttrvalue> findProductAttrvalueBySTMP(Long sysCodeId, int typeId, String matchId,
			Long productId) {
		return productAttrvalueMapper.findProductAttrvalueBySTMP(sysCodeId, typeId, matchId, productId);
	}

	@Override
	public List<Map<String, Object>> findMatchIdByAttrplanId(Long attrplanId) {
		String sql="select matchid from product_attrplan_detail pad,product_attrvalue pa"
				+ " where pad.attrplanid="+attrplanId+" and pa.id=pad.attrvalueid";
		List<Map<String, Object>> list=this.query(sql);
		return list;
	}

	@Override
	public List<Map<String, Object>> findIdBySPM(Long syscodeId, Long producId, String matchIds) {
		String sql="select id from product_attrvalue"
				+ " where syscodeid="+syscodeId+" and productid="+producId+" and matchid in ("+matchIds+")";
		
		List<Map<String, Object>> list=this.query(sql);
		
		return list;
	}
	
}
